Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use pandas.to_timedelta function instead of invoking deprecated ctor arg #918

Merged
merged 19 commits into from
Mar 12, 2024

Conversation

marscher
Copy link
Contributor

@marscher marscher commented Mar 6, 2024

Changes

Pandas 2.2 deprecated the unit argument of the Timedeltaindex constructor and suggests to use pandas.totimedelta function instaed. This PR changes this as suggested.

Related Issues

properly fixes #909

Checks

  • updated CHANGELOG.md
  • updated tests/

Copy link

github-actions bot commented Mar 6, 2024

Test Results

2 188 tests  ±0   2 187 ✅ +1   2m 45s ⏱️ -20s
    1 suites ±0       1 💤 ±0 
    1 files   ±0       0 ❌  - 1 

Results for commit 2e6c519. ± Comparison against base commit 82b79b1.

This pull request removes 62 and adds 62 tests. Note that renamed tests count towards both.
weldx.tests.test_time.TestTime ‑ test_add_datetime[TimedeltaIndex-False-False-False]
weldx.tests.test_time.TestTime ‑ test_add_datetime[TimedeltaIndex-False-False-True]
weldx.tests.test_time.TestTime ‑ test_add_datetime[TimedeltaIndex-False-True-False]
weldx.tests.test_time.TestTime ‑ test_add_datetime[TimedeltaIndex-False-True-True]
weldx.tests.test_time.TestTime ‑ test_add_datetime[TimedeltaIndex-True-False-False]
weldx.tests.test_time.TestTime ‑ test_add_datetime[TimedeltaIndex-True-False-True]
weldx.tests.test_time.TestTime ‑ test_add_datetime[TimedeltaIndex-True-True-False]
weldx.tests.test_time.TestTime ‑ test_add_datetime[TimedeltaIndex-True-True-True]
weldx.tests.test_time.TestTime ‑ test_add_timedelta[TimedeltaIndex-h-False-False-False]
weldx.tests.test_time.TestTime ‑ test_add_timedelta[TimedeltaIndex-h-False-False-True]
…
weldx.tests.test_time.TestTime ‑ test_add_datetime[to_timedelta-False-False-False]
weldx.tests.test_time.TestTime ‑ test_add_datetime[to_timedelta-False-False-True]
weldx.tests.test_time.TestTime ‑ test_add_datetime[to_timedelta-False-True-False]
weldx.tests.test_time.TestTime ‑ test_add_datetime[to_timedelta-False-True-True]
weldx.tests.test_time.TestTime ‑ test_add_datetime[to_timedelta-True-False-False]
weldx.tests.test_time.TestTime ‑ test_add_datetime[to_timedelta-True-False-True]
weldx.tests.test_time.TestTime ‑ test_add_datetime[to_timedelta-True-True-False]
weldx.tests.test_time.TestTime ‑ test_add_datetime[to_timedelta-True-True-True]
weldx.tests.test_time.TestTime ‑ test_add_timedelta[to_timedelta-h-False-False-False]
weldx.tests.test_time.TestTime ‑ test_add_timedelta[to_timedelta-h-False-False-True]
…

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Mar 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.48%. Comparing base (1750f5d) to head (2e6c519).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #918      +/-   ##
==========================================
+ Coverage   96.45%   96.48%   +0.03%     
==========================================
  Files          95       95              
  Lines        6287     6293       +6     
==========================================
+ Hits         6064     6072       +8     
+ Misses        223      221       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@marscher marscher marked this pull request as ready for review March 6, 2024 11:09
@CagtayFabry
Copy link
Member

Thanks for the fixes @marscher !

what is the minimum pandas version required for this?
Does it work with 1.5.x still?

@marscher
Copy link
Contributor Author

marscher commented Mar 6, 2024

what is the minimum pandas version required for this? Does it work with 1.5.x still?

I've added some backward compatibility code for reading old unit suffixes. Currently it only replaces the (used by weldx schema examples) suffix for seconds "S". I am not aware of any other units used in the past by weldx. To ensure we can still load old files with the new version, we should probably complete this list.

@@ -9,6 +9,14 @@
__all__ = ["TimedeltaIndexConverter"]


def _handle_converted_pd_tdi_units(node: TaggedDict):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backward compat @CagtayFabry

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changelog of pandas:

Units ‘H’, ‘T’, ‘S’, ‘L’, ‘U’ and ‘N’ are deprecated and will be removed in a future version. Please use ‘h’, ‘min’, ‘s’, ‘ms’, ‘us’, and ‘ns’ instead of ‘H’, ‘T’, ‘S’, ‘L’, ‘U’ and ‘N’.

@marscher
Copy link
Contributor Author

marscher commented Mar 6, 2024

Sorry I misinterpreted your question. I did not check, if it works with old Pandas versions. Is this a requirement or can we just pin a minimum version?

@marscher
Copy link
Contributor Author

marscher commented Mar 6, 2024

I've tested pandas-1.5 with Python-3.11 locally and all tests pass.

@marscher
Copy link
Contributor Author

marscher commented Mar 6, 2024

The CI failures are unrelated to my changes. I think this one is ready to go.

@CagtayFabry
Copy link
Member

I've tested pandas-1.5 with Python-3.11 locally and all tests pass.

If you tested it with 1.5 I am fine with pinning minimum pandas version >=1.5. 😊
I will update the CI to test for that later as well

@CagtayFabry CagtayFabry self-requested a review March 6, 2024 19:30
@marscher marscher merged commit ab583be into BAMWelDX:master Mar 12, 2024
18 of 21 checks passed
@marscher marscher deleted the pandas_upgrade_timedelta branch March 12, 2024 08:14
@CagtayFabry CagtayFabry mentioned this pull request Mar 12, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pandas warning of deprecated S
2 participants